<?php

use yii\helpers\Html;
use yii\widgets\ActiveForm;
use yii\helpers\ArrayHelper;
use common\models\fenhuicat\Fenhuicat;
use yii\helpers\Url;
/* @var $this yii\web\View */
/* @var $model common\models\fenhuicat\Fenhuicat */
/* @var $form yii\widgets\ActiveForm */
?>
<?php $this->beginBlock('siderbar'); ?>
<?= $this->render('//layouts/fenhui-menu') ?>
<?php $this->endBlock(); ?>
<?php $parentCatalog = ArrayHelper::merge([0 =>'--请选择分会--'], Fenhuicat::getArrayFenhuigrade());unset($parentCatalog[$model->id]);
?>
<?php $parent = ArrayHelper::merge([0 =>'顶级分类'], ArrayHelper::map(Fenhuicat::get(0, Fenhuicat::find()->where(['fg_id'=>$model->id])->all()), 'id', 'str_label'));unset($parentCatalog[$model->id]); ?>
<div class="fenhuicat-form">

    <?php $form = ActiveForm::begin(); ?>


    <?= $form->field($model, 'fg_id')->dropDownList($parentCatalog,
        [
            'onchange' => '
            $.post("' . yii\helpers\Url::to(['fenhuicat/getfc/']) . '/"+$(this).val(),function(data){
                $("#fenhuicat-parent_id").html(data);
            });',
        ]) ?>

    <?= $form->field($model, 'parent_id')->dropDownList($parent) ?>
    <?= $form->field($model, 'name')->textInput(['maxlength' => true]) ?>

    <?= $form->field($model, 'status')->dropDownList(array('1'=>'显示','0'=>'不显示')) ?>

    <?= $form->field($model, 'type')->textInput(['maxlength' => true]) ?>

    <?= $form->field($model, 'ctype')->textInput(['maxlength' => true]) ?>

    <?= $form->field($model, 'url')->textInput(['maxlength' => true]) ?>

    <?= $form->field($model, 'sort')->textInput() ?>

    <?= $form->field($model, 'seo_keywords')->textInput(['maxlength' => true]) ?>

    <?= $form->field($model, 'seo_contents')->textarea(['rows' => 6]) ?>
    <div class="form-group">
        <?= Html::submitButton($model->isNewRecord ? Yii::t('app', 'Create') : Yii::t('app', 'Update'), ['class' => $model->isNewRecord ? 'btn btn-success' : 'btn btn-primary']) ?>
    </div>

    <?php ActiveForm::end(); ?>

</div>
